package com.example.aircraft.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import com.example.aircraft.MyApplication;

public class MySqliteHelper extends SQLiteOpenHelper {
    /**
     *
     * @param context 上下文对象
     * @param dbName 数据库名称
     * @param factory 工厂
     * @param version 版本
     */
    public MySqliteHelper(Context context, String dbName, SQLiteDatabase.CursorFactory factory, int version){
        super(context, dbName, factory, version);
    }

    public MySqliteHelper(Context context){
        super(context, SQLiteInterface.DATABASE_NAME, null,SQLiteInterface.DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
            String sql = "create table "+SQLiteInterface.TABLE1_NAME+
                    "("+SQLiteInterface.ID+" Integer primary key ,"+
                    SQLiteInterface.USER+" varchar(50),"+
                    SQLiteInterface.SCORE+" Integer,"+
                    SQLiteInterface.TIME+" varchar(50)," +
                    SQLiteInterface.LEVEL+" Integer )";
            sqLiteDatabase.execSQL(sql);
            //                    SQLiteInterface.PASSWORD+" varchar(20) ," +
            String sql1 = "create table "+SQLiteInterface.TABLE2_NAME+
                    " ("+SQLiteInterface.USER_NAME+" varchar(50) primary key ,"+
                    SQLiteInterface.CREDITS+" Integer ," +
                    SQLiteInterface.SHIELD+" Integer ,"+
                    SQLiteInterface.CLUSTER+" Integer ,"+
                    SQLiteInterface.HEMOPHAGIA +" Integer)";
            sqLiteDatabase.execSQL(sql1);

    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

    }


}
